package com.wo.cloud.admin.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wo.cloud.admin.entity.SysLog;
import com.wo.cloud.admin.mapper.SysLogMapper;
import com.wo.cloud.admin.service.ISysLogService;
import com.wo.cloud.admin.vo.SysLogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 系统日志表 服务实现类
 * </p>
 *
 * @author liry
 * @since 2020-07-15
 */
@Service
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements ISysLogService {

    @Autowired
    private SysLogMapper sysLogMapper;

    // 分页条件查询
    @Override
    public IPage<SysLog> selectPage(Page page, SysLogVo sysLogVo) {
        QueryWrapper<SysLog> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(sysLogVo.getMethod()), "method", sysLogVo.getMethod());
        wrapper.like(StrUtil.isNotBlank(sysLogVo.getUrl()), "url", sysLogVo.getUrl());
        return sysLogMapper.selectPage(page, wrapper);
    }
}
